

def get_monomials_literals(INPUT_WIDTH):
    return ['1'] + ['x%s' % i for i in range(1, INPUT_WIDTH + 1)] + ['y%s' % i for i in range(1, INPUT_WIDTH + 1)]\
         + ['x%sy%s' % (i, j) for i in range(1, INPUT_WIDTH + 1) for j in range(1, INPUT_WIDTH + 1)]


def get_monomials_literals_alter(INPUT_WIDTH):
    return ['1'] + ['x%s' % i for i in range(1, INPUT_WIDTH + 1)] + ['y%s' % i for i in range(1, INPUT_WIDTH + 1)]\
         + ['x%sx%s' % (i, j) for i in range(1, INPUT_WIDTH + 1) for j in range(i + 1, INPUT_WIDTH + 1)]\
         + ['y%sy%s' % (i, j) for i in range(1, INPUT_WIDTH + 1) for j in range(i + 1, INPUT_WIDTH + 1)]\
         + ['x%sy%s' % (i, j) for i in range(1, INPUT_WIDTH + 1) for j in range(1, INPUT_WIDTH + 1)]

def print_answers(passed_cases, INPUT_WIDTH):
    literals = get_monomials_literals(INPUT_WIDTH)
    for item in passed_cases:
        print ' + '.join([literals[i] for i in item])


